n=int(input())
arr= [list(map(int,input().split())) for i in range(0,n)]

def getResullt():
    agent={}
    arr.sort(key=lambda x:-x[1])
    first=arr[-1][1]
    for id,preId,money in arr:
        if agent.get(id) is not None:
            money=money+agent[id]
        else:
            agent[id]=0
        if agent.get(preId) is None:
            agent[preId]=0
        agent[preId]=agent[preId]+money//100*15
    return f"{first} {agent[first]}"

print(getResullt())
# 3
# 1 0 223
# 2 0 323
# 3 2 1203

# 4
# 1 0 100
# 2 0 200
# 3 0 300
# 4 0 200



